package dome5Steam;

import java.util.*;
import java.util.stream.Stream;

public class Streamdome2 {
    public static void main(String[] args) {
        //目标：获取Stream流的方式
        System.out.println("=======1.通过集合获取=======");
        Collection<String> list=new ArrayList();
        Stream<String> s1 = list.stream();

        System.out.println("=======2.通过Map集合获取=======");
        Map<String,Integer> map=new HashMap<>();
        //获取key的Stream流
        Stream<String> s2 = map.keySet().stream();
        //获取value的Stream流
        Stream<Integer> s3 = map.values().stream();
        //获取key和value的Stream流
        Stream<Map.Entry<String, Integer>> s4 = map.entrySet().stream();
        System.out.println("=======3.通过数组获取=======");
        String[] names={"张无忌","张三丰","张翠山","张天师","张无忌"};
        Stream<String> s6 = Stream.of(names);//静态方法,可以接受可变参数
        Stream<String> s5= Arrays.stream(names);
        s5.forEach(System.out::println);
//        System.out.println("=======4.通过Stream静态方法获取=======");
    }
}
